#ifndef ____SSBASEL__SSBASE__BASE_UTIL__H__
#define ____SSBASEL__SSBASE__BASE_UTIL__H__
/*!
* \file base_util.h
* \brief
* 
*
* 
* \author patdz@qq.com
* \version 1.0
* \date 2014/05/26
*/

#include "base.h"

#ifdef _MSC_VER
#include "ssbase_win/base_win_export.h"
#endif

_SSL_BEGIN
_SSBASEL_BEGIN

//
#define SS_DIMOF _countof

//
#define SS_FLAG_SET(set, f) ((set)|=(f))
#define SS_FLAG_UNSET(set, f) ((set)&=~(f))
#define SS_FLAG_ISSET(set, f) (((set)&(f)) == (f))

//
#define SS_MIN(x, y) ((x) < (y) ? (x) : (y))
#define SS_MAX(x, y) ((x) > (y) ? (x) : (y))

//
#ifdef SS_UNICODE
#define base_assert base_assert_w
#else
#define base_assert base_assert_a
#endif

#ifdef SS_DEBUG
#ifdef UNICODE
#define SS_ASSERT(x) if (!(x)) base_assert(__FILE__, __LINE__, L#x)
#else
#define SS_ASSERT(x) if (!(x)) base_assert(__FILE__, __LINE__, #x)
#endif
#define SS_VERIFY(x) SS_ASSERT(x)
#define SS_ASSERT_HERE SS_ASSERT(__LINE__ == -1)
#else
#define SS_ASSERT(x)
#define SS_VERIFY(x) (x)
#define SS_ASSERT_HERE {}
#endif

//
SSBASE_API void* align_2byte(void *ptr);
SSBASE_API void* align_4byte(void *ptr);

//
#define MAKEINT64(h, l) ( (((long long)l) & 0xffffffff) | ((((long long)h) & 0xffffffff) << 32) )
#define HIINT64(l) ( (((long long)l) >> 32) & 0xffffffff )
#define LOINT64(l) ( ((long long)l) & 0xffffffff )



_SSBASEL_END
_SSL_END

#endif
